<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        /* 
        实现方式一
        需求：从数组中获取大于50的数据，放在新数组中
         */

        var arr=[1,51,11,5324,7,4356,234,123,51,2]
        var resultArr=[]
        var count=0
        for(var i=0; i<arr.length;i++){
            if(arr[i]>50){
                resultArr[count]=arr[i]
                count++
            }
        }
        console.log(resultArr)

        /* 
        实现方式二

         */
         var arr=[1,51,11,5324,7,4356,234,123,51,2]
         var resultArr=[]
         for(var i=0; i<arr.length;i++){
            if(arr[i]>50){
              resultArr[resultArr.length]=arr[i]
            }
        }
        console.log(resultArr)
    </script>
</head>
<body>
    
</body>
</html>